package com.taxsystem.gaozhuanglin.booking;


import com.main.taxsystem.R;
import com.taxsystem.main.MainTabActivity;
import com.taxsystem.main.TaxService;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class BookingStart extends Activity {
	
	ListView lv;
	private String[] s1 = {"综合业务", "发票管理"};
	private String[] s2 = {"2014-05-16 10:00~10:30", "2014-05-15 10:30~11:00"};
	private String[] s3 = {"已出票", "已失约"};
	
	RelativeLayout rl1;
	
	ImageView back;
	
	Button btn;
	private ActionBar bar;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bookingstart);
		
		lv = (ListView)findViewById(R.id.lb);
		rl1 = (RelativeLayout)findViewById(R.id.xy);
		btn = (Button)findViewById(R.id.bn);
		back = (ImageView)findViewById(R.id.ivBack);
		
		bar = getActionBar();
		bar.hide();
		
		BaseAdapter adapter = new BaseAdapter()
		{

			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return 2;
			}

			@Override
			public Object getItem(int arg0) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public long getItemId(int position) {
				// TODO Auto-generated method stub
				return position;
			}

			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				// TODO Auto-generated method stub
				RelativeLayout rl = (RelativeLayout) getLayoutInflater().inflate(R.layout.bitem, null);
				TextView tv1 = (TextView)rl.findViewById(R.id.he2);
				tv1.setText(s1[position]);
				TextView tv2 = (TextView)rl.findViewById(R.id.ti2);
				tv2.setText(s2[position]);
				TextView tv3 = (TextView)rl.findViewById(R.id.pd);
				tv3.setText(s3[position]);
				if(s3[position].equals("已出票"))
				{
					tv3.setTextColor(0xff6bcf48);
				}
				else if(s3[position].equals("已失约"))
				{
					tv3.setTextColor(0xfffb8281);
				}
				return rl;
			}
			
		};
		lv.setAdapter(adapter);
		
		rl1.setOnTouchListener(new OnTouchListener()
		{

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				// TODO Auto-generated method stub
				Intent intent1 = new Intent(BookingStart.this, BookingShow.class);
				startActivity(intent1);
				
				return false;
			}
			
		});
		
		lv.setOnItemClickListener(new OnItemClickListener()
		{

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				
			}
		});
		
		btn.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent2 = new Intent(BookingStart.this, TicketItemActivity.class);
				startActivity(intent2);
			}
		});
		
		back.setOnTouchListener(new OnTouchListener()
		{

			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				// TODO Auto-generated method stub
				Intent intent_back = new Intent(BookingStart.this,MainTabActivity.class);
				startActivity(intent_back);
				
				return false;
			}
			
		});
	}

}
